#ifndef APPCONTROLLER_H_
#define APPCONTROLLER_H_

#include <MAUtil/Moblet.h>
#include <MAUtil/Map.h>
#include <MAUtil/Stack.h>
#include <MAUI/Screen.h>
#include <MAUI/Font.h>
#include "DAOs/DTO.h"
#include "ScreenTransition.h"
#include "Utilities/XmlConnection.h"

#define APPCONTROLLER AppController::getInstance()

using namespace MAUtil;
using namespace MAUI;

class AppController
{
	public:
		~AppController();

		static AppController* getInstance();

		Moblet* getMoblet();
		void setMoblet(Moblet* moblet);

		void registerScreen(String screenName, Screen* screen);
		int registerScreen(Screen* screen);

		void show(String screenName);
		void show(int screenIndex);

		Screen* getScreen(int screenIndex);
		Screen* getScreen(String screenName);

		void back();
		void close();

        void addFont(String name, Font* font);
        Font* getFont(String name);

        void addSkin(String name, WidgetSkin* skin);
        WidgetSkin* getSkin(String name);

        int getScreenWidth();
        int getScreenHeight();

        int getDataTransfer();
        void setDataTransfer(int input);

        String& getCompanyId();
        void setCompanyId(String& value);

        XmlConnection* getConnection();

        Vector<LRESItem> mLRESList;
        bool mIsGetLRES;

        String& getUrl();
        int getNew();
        String& getUserInfoValue();

        void abortRegister();

	protected:
		AppController();

	private:
		static AppController* mInstance;

		void getUserInfo();

		Moblet* mMoblet;

		HashMap<String, int> mIndex;
		Vector<Screen*> mScreens;
		Stack<int> mHistory;

		int getIndex(String& screenName);

	    HashMap<String, Font*> mFonts;
	    HashMap<String, WidgetSkin*> mSkins;

	    int mScrWidth;
	    int mScrHeight;

	    int mDataTransfer;

	    int mNew;
	    String mUserInfo;

	    String mCompanyId;
	    String mUrl;

	    XmlConnection* mConn;
};

#endif /* APPCONTROLLER_H_ */
